from tkinter import *


class HelloPackge:
    def __init__(self, parent=None):
        self.top = Frame(parent)
        self.top.pack()
        self.data = 0
        self.make_widgets()

    def make_widgets(self):
        Button(self.top, text="按钮1", command=self.top.quit).pack(side=LEFT)
        Button(self.top, text="按钮2", command=self.message).pack(side=RIGHT)

    def message(self):
        self.data += 1
        print("data的值：", self.data)


HelloPackge().top.mainloop()
